package com.common.help;

import java.util.Set;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.common.util.DateUtils;
import com.common.util.HttpClientUtil;
import com.common.util.RedisClient;

@RunWith(SpringJUnit4ClassRunner.class)  
@ContextConfiguration(locations={"classpath:config/applicationContext-jta.xml"})
public class TestRedis {
		
		@Resource(name="redisClient")
		private RedisClient redisClient;
		
		public final static String PER = "per";
		public final static String After = "after"; 
		
		@Test
		public void testRedis(){
			Set<String> parkSet = redisClient.getMapAllKeys("parkNo_seq:"); 
			for(String str:parkSet){
					redisClient.deleteMapMember("parkNo_seq:", str);
					redisClient.incr("aa");
			}
			//序列自增
			
			String time = DateUtils.getNowStrDate1();
			String date = time.substring(0, 8);
			String per = redisClient.get(PER);
			String after = redisClient.incr(After);
			if(StringUtils.isBlank(per)||!date.equals(per)){
				per = date;
				after = "1";
				redisClient.set(After,after);
			}
			redisClient.set(PER, date);
			StringBuffer bf = new StringBuffer();
			for(int i=0;i<7-after.length();i++){
				bf.append("0");
			}
			String aa =  "PR"+time+bf+after;
			System.out.println(aa);
		}
		@Test
		public void test11(){
			for(;;){
			System.out.println(HttpClientUtil.doGet("http://192.168.10.97:6080/hello/test1"));
			}
		}
}
